home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 June / macformat-038.iso / Demos / Notting Hill / ATHLETICS / COMMNT / 00002_Navigational Handling.ls < prev    next >
Encoding:
Text File  |  1996-02-08  |  10.9 KB  |  350 lines

  1. on enterFrame
  2.   global NewScreenID, BaseChannel, LastChannel, NumChannel, OverChannel, GfxChannel, SeqChannel, DVidChannel, CurtainChannel, first, CurrScreenID, AllScreen, offList, rollList, clickList, ActList, ScreenCast, ScreenLinks, NumActive, NumChannels, cenX, cenY, StickH, StickV
  3.   if NewScreenID then
  4.     set CurrScreenID to NewScreenID
  5.     if first then
  6.       set first to 0
  7.       repeat with J = BaseChannel to LastChannel
  8.         puppetSprite(J, 1)
  9.       end repeat
  10.       puppetSprite(31, 1)
  11.       puppetSprite(OverChannel, 1)
  12.       puppetSprite(OverChannel + 1, 1)
  13.       puppetSprite(GfxChannel, 1)
  14.       puppetSprite(SeqChannel, 1)
  15.       puppetSprite(DVidChannel, 1)
  16.       puppetSprite(CurtainChannel, 1)
  17.     end if
  18.     set ScreenInfo to getAt(AllScreen, NewScreenID)
  19.     set ChangePalette to 0
  20.     if ScreenCast <> -1 then
  21.       set PalA to the palette of cast ScreenCast
  22.     else
  23.       set ChangePalette to 1
  24.     end if
  25.     set ScreenCast to getAt(ScreenInfo, 1)
  26.     if ScreenCast <> -1 then
  27.       set PalB to the palette of cast ScreenCast
  28.     end if
  29.     if PalA <> PalB then
  30.       set ChangePalette to 1
  31.     end if
  32.     if ChangePalette then
  33.       puppetPalette("Black", 27)
  34.     end if
  35.     puppetSprite(BaseChannel, 1)
  36.     set the castNum of sprite BaseChannel to ScreenCast
  37.     puppetSprite(48, 1)
  38.     set the castNum of sprite 48 to 15
  39.     puppetSprite(CurtainChannel, 1)
  40.     set the castNum of sprite CurtainChannel to ScreenCast
  41.     if ChangePalette then
  42.       updateStage()
  43.       puppetPalette(PalB, 27)
  44.     end if
  45.     set ScreenLinks to [getAt(ScreenInfo, 2)]
  46.     append(ScreenLinks, getAt(ScreenInfo, 3))
  47.     append(ScreenLinks, getAt(ScreenInfo, 4))
  48.     NavSprites(ScreenLinks)
  49.     set offList to []
  50.     set rollList to []
  51.     set clickList to []
  52.     set ActList to []
  53.     set CurrChannel to BaseChannel + 1
  54.     set NumActive to 0
  55.     repeat with Element in ScreenInfo
  56.       if listp(Element) then
  57.         set NumActive to NumActive + 1
  58.         put "Element = " & Element
  59.         append(offList, getAt(Element, 1))
  60.         set ActID to count(Element)
  61.         if ActID = 2 then
  62.           set RollID to 1
  63.           set ClickID to 1
  64.         else
  65.           if ActID = 3 then
  66.             set RollID to 2
  67.             set ClickID to 2
  68.           else
  69.             if ActID = 4 then
  70.               set RollID to 2
  71.               set ClickID to 3
  72.             end if
  73.           end if
  74.         end if
  75.         append(rollList, getAt(Element, RollID))
  76.         append(clickList, getAt(Element, ClickID))
  77.         append(ActList, getAt(Element, ActID))
  78.         puppetSprite(CurrChannel, 1)
  79.         put "setting " & CurrChannel & " to " & getAt(Element, 1)
  80.         set the castNum of sprite CurrChannel to getAt(Element, 1)
  81.         set CurrChannel to CurrChannel + 1
  82.       end if
  83.     end repeat
  84.     repeat with J = NumActive + 1 to NumChannels - 1
  85.       puppetSprite(CurrChannel, 1)
  86.       set the castNum of sprite CurrChannel to 3
  87.       set the locH of sprite CurrChannel to 320
  88.       set the locV of sprite CurrChannel to 240
  89.       set CurrChannel to CurrChannel + 1
  90.     end repeat
  91.     ResetRoll()
  92.     resetGfx()
  93.     resetSeq()
  94.     resetVideo()
  95.     if ScreenCast = 107 then
  96.       set the moveableSprite of sprite LastChannel to 1
  97.       puppetSprite(5, 1)
  98.       set the castNum of sprite 5 to 701
  99.       set cenX to 315
  100.       set cenY to 260
  101.       repeat with k = LastChannel down to LastChannel - 9
  102.         set the castNum of sprite k to 91 + (k - LastChannel + 9)
  103.         set f to (k - LastChannel + 9) / 10.0
  104.         set dx to 320 - cenX
  105.         set dy to 240 - cenY
  106.         set the locH of sprite k to cenX + (f * dx)
  107.         set the locV of sprite k to cenY + (f * dy)
  108.       end repeat
  109.     else
  110.       set the moveableSprite of sprite LastChannel to 0
  111.       set the castNum of sprite 5 to 3
  112.     end if
  113.     set the castNum of sprite 48 to 3
  114.     set the castNum of sprite CurtainChannel to 3
  115.     set StickH to 180
  116.     set StickV to 120
  117.   end if
  118. end
  119.  
  120. on exitFrame
  121.   global CurrScreenID, offList, AddScreeb, BaseChannel, bDrag, bDragging, NumActive, EndChannel, NumChannels, Issue, OverChannel, NewScreenID, ScreenCast, LastChannel, cenX, cenY, StickH, StickV
  122.   set c to the mouseCast
  123.   if NewScreenID then
  124.     set NewScreenID to 0
  125.     set the castNum of sprite 31 to 211
  126.     set the visible of sprite 31 to CurrScreenID = 7
  127.   end if
  128.   if (c < 5) or (c > 7) or bDragging then
  129.     set ActiveChannel to 0
  130.     set StdCursor to 1
  131.     set rollAt to getPos(rollList, c)
  132.     if not bDragging then
  133.       set the castNum of sprite (OverChannel + 1) to 3
  134.       if rollAt then
  135.         set ActiveChannel to rollAt + BaseChannel
  136.         if soundBusy(2) then
  137.           go(the frame)
  138.           exit
  139.         end if
  140.         if the mouseDown and not bDrag then
  141.           cursor(200)
  142.           set the castNum of sprite OverChannel to getAt(clickList, rollAt)
  143.           updateStage()
  144.           repeat while the mouseDown
  145.           end repeat
  146.           cursor(0)
  147.           decode(getAt(ActList, rollAt))
  148.         end if
  149.       else
  150.         set offAt to getPos(offList, c)
  151.         if offAt then
  152.           set ActiveChannel to offAt + BaseChannel
  153.           put "Sprite = " & ActiveChannel & " change to cast " & getAt(rollList, offAt)
  154.           puppetSprite(ActiveChannel, 1)
  155.           set the castNum of sprite OverChannel to getAt(rollList, offAt)
  156.         end if
  157.       end if
  158.       if ActiveChannel then
  159.         set StdCursor to 0
  160.         cursor([28, 29])
  161.       else
  162.         if not bDrag then
  163.           ResetHighChannels()
  164.         end if
  165.       end if
  166.     else
  167.       set expert to the mouseCast - 244
  168.       repeat with J = 0 to 3
  169.         set the castNum of sprite (14 + J) to 244 + (J * 2)
  170.       end repeat
  171.       if (expert >= 0) and (expert <= 7) then
  172.         put "Mousecast on drag expert " & expert
  173.         set the castNum of sprite (14 + (expert / 2)) to expert + 245
  174.       end if
  175.     end if
  176.     if bDragging then
  177.       cursor([38, 39])
  178.       set StdCursor to 0
  179.       if the mouseUp then
  180.         set ComExpert to expert
  181.         set expert to 1 + (expert / 2)
  182.         set CastDo to ((Issue - 1) * 4) + (expert - 1)
  183.         if (expert >= 1) and (expert <= 4) then
  184.           set CastDo to 501 + CastDo
  185.           put "Issue = " & Issue & " put to expert " & expert & " play cast " & CastDo
  186.           playVideo(CastDo, 329, 237)
  187.           set comCastBack to (ComExpert / 2 * 2) + 244
  188.           set the castNum of sprite (14 + (ComExpert / 2)) to comCastBack
  189.           put "Cast back to " & comCastBack
  190.         else
  191.           put "That's not an expert"
  192.         end if
  193.       end if
  194.     end if
  195.     if not bDragging then
  196.       set bDrag to 0
  197.       if (c = 232) or ((c >= 301) and (c <= 304)) then
  198.         set bDrag to 1
  199.         set k to 3.60000000000000009 * (the mouseV - the top of the rect of cast 232) / (1.0 * the height of cast 232)
  200.         set currline to 301 + integer(k)
  201.         if currline > 304 then
  202.           set currline to 304
  203.         end if
  204.         set the castNum of sprite (OverChannel + 1) to currline
  205.         set Issue to currline - 300
  206.         if Issue > 4 then
  207.           set Issue to 4
  208.         end if
  209.         put "Issue = " & Issue
  210.       else
  211.         if (c = 237) or ((c >= 311) and (c <= 315)) then
  212.           set bDrag to 1
  213.           set k to 4.20000000000000018 * (the mouseV - the top of the rect of cast 237) / (1.0 * the height of cast 237)
  214.           set currline to 311 + integer(k)
  215.           set the castNum of sprite (OverChannel + 1) to currline
  216.           set Issue to currline - 306
  217.           if Issue > 9 then
  218.             set Issue to 9
  219.           end if
  220.           put "Issue = " & Issue
  221.         end if
  222.       end if
  223.       if bDrag then
  224.         cursor([28, 29])
  225.         set StdCursor to 0
  226.       end if
  227.     end if
  228.     if bDrag and the mouseDown then
  229.       if (Issue = 1) or (Issue = 5) then
  230.         if Issue = 1 then
  231.           nothing()
  232.           set helpCast to 256
  233.         else
  234.           if Issue = 5 then
  235.             nothing()
  236.             set helpCast to 259
  237.           end if
  238.         end if
  239.         ResetHighChannels()
  240.         set the castNum of sprite OverChannel to helpCast
  241.         updateStage()
  242.         repeat while the mouseDown
  243.         end repeat
  244.       else
  245.         set bDragging to 1
  246.       end if
  247.     else
  248.       set bDragging to 0
  249.     end if
  250.     if StdCursor then
  251.       cursor(0)
  252.     end if
  253.   else
  254.     if c = 7 then
  255.       cursor([22, 23])
  256.       if the mouseDown then
  257.         set NewScreenID to getAt(ScreenLinks, 3)
  258.       end if
  259.     else
  260.       if c = 5 then
  261.         cursor([20, 21])
  262.         if the mouseDown then
  263.           set NewScreenID to getAt(ScreenLinks, 1)
  264.         end if
  265.       else
  266.         cursor([24, 25])
  267.         if the mouseDown then
  268.           set NewScreenID to getAt(ScreenLinks, 2)
  269.         end if
  270.       end if
  271.     end if
  272.     ResetHighChannels()
  273.   end if
  274.   if ScreenCast = 107 then
  275.     set sweep to 20
  276.     if the locH of sprite LastChannel < (320 - sweep) then
  277.       set the locH of sprite LastChannel to 320 - sweep
  278.     else
  279.       if the locH of sprite LastChannel > (320 + sweep) then
  280.         set the locH of sprite LastChannel to 320 + sweep
  281.       end if
  282.     end if
  283.     if the locV of sprite LastChannel < (240 - sweep) then
  284.       set the locV of sprite LastChannel to 240 - sweep
  285.     else
  286.       if the locV of sprite LastChannel > (240 + sweep) then
  287.         set the locV of sprite LastChannel to 240 + sweep
  288.       end if
  289.     end if
  290.     set dx to the locH of sprite LastChannel - 320
  291.     set dy to the locV of sprite LastChannel - 240
  292.     set vX to the locH of sprite LastChannel - cenX
  293.     set vY to the locV of sprite LastChannel - cenY
  294.     if the mouseDown then
  295.       if c = 100 then
  296.         set the locH of sprite LastChannel to the mouseH - StickH
  297.         set the locV of sprite LastChannel to the mouseV - StickV
  298.       end if
  299.       repeat with k = 0 to 9
  300.         set f to k / 10.0
  301.         set the locH of sprite (LastChannel - 9 + k) to cenX + (f * vX)
  302.         set the locV of sprite (LastChannel - 9 + k) to cenY + (f * vY)
  303.       end repeat
  304.     else
  305.     end if
  306.     set the locH of sprite 5 to the locH of sprite 5 - (dx / 2)
  307.     set the locV of sprite 5 to the locV of sprite 5 - (dy / 2)
  308.     set limitL to 217
  309.     set limitR to 681
  310.     set limitT to 21
  311.     set limitB to 398
  312.     if the locH of sprite 5 < limitL then
  313.       set the locH of sprite 5 to limitL
  314.     end if
  315.     if the locH of sprite 5 > limitR then
  316.       set the locH of sprite 5 to limitR
  317.     end if
  318.     if the locV of sprite 5 < limitT then
  319.       set the locV of sprite 5 to limitT
  320.     end if
  321.     if the locV of sprite 5 > limitB then
  322.       set the locV of sprite 5 to limitB
  323.     end if
  324.   end if
  325.   if NewScreenID then
  326.     put "Going to " & NewScreenID
  327.     repeat while the mouseDown
  328.     end repeat
  329.   end if
  330.   go(the frame)
  331. end
  332.  
  333. on ResetHighChannels
  334.   global OverChannel
  335.   set the castNum of sprite OverChannel to 3
  336.   set the castNum of sprite (OverChannel + 1) to 3
  337. end
  338.  
  339. on NavSprites ScreenLinks
  340.   repeat with J = 1 to 3
  341.     set ch to 44 + J
  342.     puppetSprite(ch, 1)
  343.     if getAt(ScreenLinks, J) then
  344.       set the visible of sprite ch to 1
  345.       next repeat
  346.     end if
  347.     set the visible of sprite ch to 0
  348.   end repeat
  349. end
  350.